/**
 * Created by baidm in 2022/4/17 on 20:24
 */
export default function (bgSrc, src) {
    return new Promise(resolve => {
        let canvas = document.createElement('canvas');
        canvas.width = 200;
        canvas.height = 200;
        let context = canvas.getContext('2d');
        context.rect(0, 0, canvas.width, canvas.height);
        let bgImg = new Image();
        bgImg.src = bgSrc;    // 背景图的url
        bgImg.crossOrigin = 'Anonymous';
        bgImg.onload = () => {
            context.drawImage(bgImg, 0, 0, 200, 200);
            let img = new Image();
            img.src = src;    // 需要合进去的图片url
            img.crossOrigin = 'Anonymous';
            img.onload = () => {
                context.drawImage(img, 75, 50, 50, 50);
                let base64 = canvas.toDataURL('image/png');
                resolve(base64)
            }
        }
    })
}